package com.lagou.mr.homework;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class SortReducer extends Reducer<SortBean, NullWritable,SortBean, NullWritable> {
    int sum = 1;
    @Override
    protected void reduce(SortBean key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        // 重写reduce方法
        //遍历，累加id的值

        for (NullWritable value : values) {
            key.setId(sum);
            sum += 1;
            context.write(key,NullWritable.get());
        }
    }
}
